package com.ax.center.controller;

import com.ax.center.annotation.Logging;
import com.ax.center.dto.ApiResponse;
import com.ax.center.entity.UserAuth;
import com.ax.center.service.UserAuthService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author zy
 * @date 2023/7/6 14:28
 */

@RestController
@RequestMapping(value = "/userAuthController")
@Api(tags = "用户权限服务")
@CrossOrigin(origins = "http://localhost:5173")
public class UserAuthController {

    @Autowired
    private UserAuthService userAuthService;

    @PostMapping("/无效的请求")
    public void test(@RequestBody UserAuth userAuth){
        return;
    }

    @GetMapping(value = "/queryAuthByUserId/{userId}")
    @ApiOperation("查询一个人的权限")
    @Logging(description = "查询一个人的权限")
    public ApiResponse queryAuthByUserId(@PathVariable("userId") Long userId){
        List<Long> list = userAuthService.queryAuthByUserId(userId);
        return ApiResponse.ok(list);
    }

    @GetMapping(value = "/deleteById/{staffId}/{authId}")
    @ApiOperation("删除用户的一个权限")
    @Logging(description = "删除用户的一个权限")
    public ApiResponse deleteById(@PathVariable("staffId") Long staffId,@PathVariable("authId")Long authId){
        return userAuthService.deleteById(staffId,authId);
    }
    @GetMapping(value = "/insertById/{staffId}/{authId}")
    @ApiOperation("添加用户的一个权限")
    @Logging(description = "添加用户的一个权限")
    public ApiResponse insertById(@PathVariable("staffId") Long staffId,@PathVariable("authId")Long authId){
        return userAuthService.insertById(staffId,authId);
    }


}
